﻿using System;
using System.Windows.Forms;

using FPISystem.Forms;
using FPISystem.Model;

namespace FPISystem
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            UserLogin();
            //Application.Run(new FPISystem.Test.InserSuperUser());
            //Application.Run(new FPISystem.Test.Test_Match());
        }

        private static void UserLogin()
        {
            Users User;
            bool IsSuperUser;
            bool IsDoct;
            Login loginForm = new Login();
            DialogResult result = loginForm.ShowDialog();
            if (result == DialogResult.OK)
                while (!loginForm.IsAvail)
                {
                    //MessageBox.Show("登录失败！该指纹为不合法用户！", "登录失败",MessageBoxButtons.OK,MessageBoxIcon.Warning);
                    loginForm.ShowDialog();
                    if (loginForm.Exit)
                        Application.Exit();
                }
            else
                Application.Exit();
            if (!loginForm.IsAvail)
                Application.Exit();
            else
            {//登录成功
                User = loginForm.User;
                IsSuperUser = loginForm.IsSuperUser;
                IsDoct = loginForm.IsDoct;

                if (IsSuperUser)
                {
                    DoctInfoManager dimForm = new DoctInfoManager();
                    dimForm.IsSuperUser = true;
                    dimForm.User = User;
                    Application.Run(dimForm);
                    //dimForm.Show();
                }
                else 
                {
                    MainForm mainForm = new MainForm();
                    mainForm.User = User;
                    mainForm.IsSuperUser = IsSuperUser;
                    mainForm.IsDoct = IsDoct;
                    Application.Run(mainForm);
                   // mainForm.Show();
                }
            }
        }
    }
}